import java.lang.*;
import java.util.*;
import java.io.*;

public class GoogleCodeJam {
    public static void main(String[] args) throws FileNotFoundException {

        /*FileInputStream instream = null;
        PrintStream outstream = null;
        
        try{
            instream = new FileInputStream("D:\\workspace\\1.txt");
            outstream = new PrintStream("D:\\workspace\\1.out");
            System.setIn(instream);
            System.setOut(outstream);
        }
        catch(Exception e){
            System.err.println("Error Occurred");
        }

        Scanner in = new Scanner(System.in);*/
    	
    	System.out.println("Working Directory = " +
                System.getProperty("user.dir"));
    	
    	ACMOj iox = new ACMOj("D:\\workspace\\1.txt","D:\\workspace\\1.out");
    	 
        int T = iox.nextInt();
        //System.out.println(T);
        
        for(int i=0;i<T;i++)
        {
        	int charNumber = iox.nextInt();
        	int number = iox.nextInt();
        	
        	// go to real next line
        	iox.nextLine();
        	
        	for(int j=0;j<2;j++)
        	{
        		String buffer = iox.nextLine();
        		System.out.println(buffer);
        	}
        }
        
        

        /*ArrayList<String> first = new ArrayList<String>();
        ArrayList<String> second = new ArrayList<String>();
        
        //        for(;in.hasNext();){
            for(int j=0;j<T;j++) {
                int number = in.nextInt();
                int size = in.nextInt();
                
                for(int k=0;k<number;k++){
                    StringBuilder str1 = new StringBuilder();
                    
                    for(int m=0;m<size;m++) {
                        char c = (char)in.next().charAt(0);
                        str1.append(c);
                    }
                    
                }
                        
            
            }
        //        }

        String[] strings = { " Hello ", " This ", "is ", "Sorting ", "Example" };
        Arrays.sort(strings);

        for(int j=0;j<strings.length;j++)
        System.out.println(strings[j]);

        System.err.println("done.");*/
        //return;
    }
}
